var Login = require ("Controls/Login")
var qcloud = require ("vendor/wafer2-client-sdk/index")
var config = require ("config")
var util = require ("utils/util")


var globalData =
{
  //是否已经登录标记
  isLogin:false,
  enableEncashment:false,
  
  address:[],
  credit:
  {
    id: -1,
    balance: 0.00,
    created_at:"1970-01-01:24:00:00.000Z",
    publishTimes:0,
    updated_at: "1970-01-01:24:00:00.000Z",
  },
  userInfo:
  {
    nickName: "empty",
    avatarUrl:"",
    userId: -1,
    qrcode:''
  },

  //用户授权信息
  authSetting:{},
  
  //我的秘袋信息
  myInfo:
  {
    published:0,
    attanded:0,
    acquired:0,
    qrcode:"",
    balance:0,
  },

  //我发布的秘袋信息
  myPublished:
  {
    page:1,
    maxPage:0,
    items:[],
  },

  //我参与的秘袋信息
  myAttanded:
  {
    page:1,
    maxPage:0,
    items:[],
  },

  //我获得的秘袋信息
  myQuired:
  {
    page:1,
    maxPage:0,
    items:[],
  }
}

function onLaunch(options)
{
  console.log(options);
  // 展示本地存储能力
  var logs = wx.getStorageSync('logs') || []
  logs.unshift(Date.now())
  wx.setStorageSync('logs', logs)

  qcloud.setLoginUrl(config.loginUrl);  

  var that = this;
  //获取授权信息
  wx.getSetting({
    success(res) {
      console.log(res.authSetting)
      that.globalData.authSetting = res.authSetting;
    },
    fail()
    {

    }
  });
}

var options =
{
  globalData,
  onLaunch,
}

//app.js
App(options)